use std::ffi::c_void;

pub fn is_void_null(h: *const c_void) -> bool {
    h == (0 as *const c_void)
}

#[derive(Debug, Copy)]
pub struct Handle {
    pub h: Option<*const c_void>,
}

impl Clone for Handle {
    fn clone(&self) -> Self {
        Self { h: self.h.clone() }
    }
}

impl Default for Handle {
    fn default() -> Self {
        Self { h: None }
    }
}

impl Handle {
    pub fn new(h: *const c_void) -> Self {
        if is_void_null(h) {
            Self { h: None }
        } else {
            Self { h: Some(h) }
        }
    }
    pub fn handle(&self) -> Option<*const c_void> {
        self.h.clone()
    }

}
